package com.example.administrator.testxingpiao.bean;

import android.support.annotation.NonNull;

import com.example.administrator.testxingpiao.utils.PinYinUtil;

public class CityBean implements Comparable<CityBean> {

    private String name;
    private String pinyin;

    //public CityBean() {}

    public CityBean(String name) {
        this.name = name;
        //在此处直接将name转换成对应的拼音.
        this.pinyin = PinYinUtil.getPinYin(name);
    }

    public String getName() {
        return name;
    }

    //public void setName(String name) {
    //    this.name = name;
    //}

    public String getPinyin() {
        return pinyin;
    }

    //public void setPinyin(String pinyin) {
    //    this.pinyin = pinyin;
    //}

    //如果返回值<0:表示当前值<another的值;
    //如果返回值>0:表示当前值>another的值;
    //如果返回值=0:表示当前值=another的值.
    @Override
    public int compareTo(@NonNull CityBean friend) {

        return this.pinyin.compareTo(friend.getPinyin());
    }
}
